from decimal import Decimal, ROUND_HALF_EVEN


def _y(x: Decimal) -> Decimal:
    factor = x.__floor__() // 1000
    factor = 10 - min(factor, 3)
    return Decimal(factor) / 10 * x


def quantize_money(value: Decimal, rounding=ROUND_HALF_EVEN):
    return value.quantize(Decimal("0.00"), rounding=rounding)


def _main():
    try:
        x = Decimal(input("请输入所花的钱 x ："))
    except ValueError:
        print("输入有误，请检查。")
        return
    print(f"所付钱 y 为 {quantize_money(_y(x))} （四舍六入）")


if __name__ == "__main__":
    _main()
